t = int(input())
arr = list(map(int, input().split()))
ans = float("inf")
for i in range(t):
floor = i
count = 0
for j in range(len(arr)):
new = abs(j - floor)
new += j
new += floor
new *= 2
new *= arr[j]
count+= new
ans = min(ans, count)
print(ans)
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
scanf("%d", &n);
int a[n];
for(int i = 0; i < n; i++){
scanf("%d", a+i);
}
int x = 1e9;
for(int f = 0; f < n; f++){
int y = 0;
for(int i = 0; i < n; i++){
int cost = abs(f - i) + i + f;
cost += cost;
y += cost * a[i];
}
x = min(x, y);
}
printf("%d\n", x);
return 0;
}
1728D - Letter Picking | 792B - Counting-out Rhyme |
1195A - Drinks Choosing | 5D - Follow Traffic Rules |
1272A - Three Friends | 1632D - New Year Concert |
1400D - Zigzags | 716C - Plus and Square Root |
412A - Poster | 844B - Rectangles |
1591A - Life of a Flower | 1398C - Good Subarrays |
629A - Far Relative’s Birthday Cake | 1166A - Silent Classroom |
1000B - Light It Up | 218B - Airport |
1463B - Find The Array | 1538C - Number of Pairs |
621B - Wet Shark and Bishops | 476B - Dreamoon and WiFi |
152C - Pocket Book | 1681D - Required Length |
1725D - Deducing Sortability | 1501A - Alexey and Train |
721B - Passwords | 1263D - Secret Passwords |
1371B - Magical Calendar | 1726E - Almost Perfect |
1360C - Similar Pairs | 900A - Find Extra One |